<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Index Terms</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Index Terms' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inbuildn.html">Inbuild Modules</a></li><li><a href="index.html">supervisor</a></li><li><a href="index.html#7">Chapter 7: Extension Management</a></li><li><b>Index Terms</b></li></ul></div>
<p class="purpose">Hypothetical index entries with no references to position as yet.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>A "term" is something which might occur as an index entry: for example,
"rockets: Titan IV". Its individual parts, here "rockets" and "Titan IV",
are called "subterms", and each can have a different category. If this term
were to be placed in a dictionary, "Titan IV" would probably end up as one of
many lemmas under the lemma "rockets".
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">texts</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">indexing_category</span><span class="plain-syntax"> *</span><span class="identifier-syntax">categories</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::new_normalised</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::new_normalised</span></span>:<br/><a href="7-it.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure normalised_term is accessed in 7/gi and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>We begin with raw text taken from the documentation source, such as
<span class="extract"><span class="extract-syntax">rockets++hardware++: ~Titan IV~</span></span>. We parse this into its subterms, and
remove any indexing notations, which convey the categories to be used.
</p>

<p class="commentary">The "adjusting" version of this function takes a Markdown node as a further
argument, and actually modifies that node. The idea is to be able to deal
with something like <span class="extract"><span class="extract-syntax">the ^{~Atlas V~} was...</span></span>, where an index marker node
is immediately followed by a plain-text node so that the words "Atlas V"
are both indexed and also included in the body text. We modify such that any
notation we parse from the index marker node (here, the tildes) is removed
from the plain node.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::parse_normalised</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::parse_normalised</span></span>:<br/><a href="7-it.html#SP4_4">&#167;4.4</a><br/>Index Lemmas - <a href="7-il.html#SP6">&#167;6</a>, <a href="7-il.html#SP7">&#167;7</a>, <a href="7-il.html#SP8">&#167;8</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><a href="7-it.html#SP1" class="function-link"><span class="function-syntax">IndexTerms::new_normalised</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="7-it.html#SP2" class="function-link"><span class="function-syntax">IndexTerms::parse_normalised_prim</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::parse_normalised_adjusting</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::parse_normalised_adjusting</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><a href="7-it.html#SP1" class="function-link"><span class="function-syntax">IndexTerms::new_normalised</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="7-it.html#SP2" class="function-link"><span class="function-syntax">IndexTerms::parse_normalised_prim</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::parse_normalised_prim</span><span class="plain-syntax">(</span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> *</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">markdown_item</span><span class="plain-syntax"> *</span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Str::copy</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Str::trim_white_space</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">" *(%c+?) *: *(%c+) *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><a href="7-it.html#SP2" class="function-link"><span class="function-syntax">IndexTerms::parse_normalised_prim</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::copy</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">plain_md</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"too deep"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">index_markup_notation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">imn</span><span class="plain-syntax"> = </span><a href="7-imn.html#SP1" class="function-link"><span class="function-syntax">IndexMarkupNotations::match</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">imn</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"not exhaustive"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax"> = </span><a href="7-imn.html#SP1" class="function-link"><span class="function-syntax">IndexMarkupNotations::left_width</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">imn</span><span class="plain-syntax">), </span><span class="identifier-syntax">R</span><span class="plain-syntax"> = </span><a href="7-imn.html#SP1" class="function-link"><span class="function-syntax">IndexMarkupNotations::right_width</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">imn</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">=</span><span class="identifier-syntax">L</span><span class="plain-syntax">; </span><span class="identifier-syntax">j</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">) - </span><span class="identifier-syntax">R</span><span class="plain-syntax">; </span><span class="identifier-syntax">j</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">], </span><span class="identifier-syntax">Str::get_at</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">, </span><span class="identifier-syntax">j</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">] = </span><a href="7-imn.html#SP1" class="function-link"><span class="function-syntax">IndexMarkupNotations::category</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">imn</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">type</span><span class="plain-syntax"> == </span><span class="identifier-syntax">PLAIN_MIT</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">from</span><span class="plain-syntax"> += </span><span class="identifier-syntax">L</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">plain_md</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">to</span><span class="plain-syntax"> -= </span><span class="identifier-syntax">R</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">trimmed</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">N</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>A "categorised" term is the next stage of processing. They are made only from
normalised terms, and as data structures look very similar, but making them
different types avoids bugs where we've somehow allowed uncategorised terms
through into the final index.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">texts</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">indexing_category</span><span class="plain-syntax"> *</span><span class="identifier-syntax">categories</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">erroneous</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::new_categorised</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::new_categorised</span></span>:<br/><a href="7-it.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">erroneous</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure categorised_term is accessed in 7/gi and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>Categorised terms are constructed only from normalised terms, and they make
a deep copy of all of the data.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::categorise</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::categorise</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP7_2">&#167;7.2</a>, <a href="7-il.html#SP8">&#167;8</a>, <a href="7-il.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="7-it.html#SP4" class="function-link"><span class="function-syntax">IndexTerms::categorise_prim</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::categorise_unrelocated</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::categorise_unrelocated</span></span>:<br/><a href="7-it.html#SP4_4">&#167;4.4</a><br/>Index Lemmas - <a href="7-il.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="7-it.html#SP4" class="function-link"><span class="function-syntax">IndexTerms::categorise_prim</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::categorise_prim</span><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_relocation</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="7-it.html#SP3" class="function-link"><span class="function-syntax">IndexTerms::new_categorised</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> = </span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0, </span><span class="identifier-syntax">ip</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">ip</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">lemma</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">indexing_category</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ic</span><span class="plain-syntax"> = </span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">];</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-it.html#SP4_1" class="named-paragraph-link"><span class="named-paragraph">Redirect category names starting with an exclamation</span><span class="named-paragraph-number">4.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-it.html#SP4_2" class="named-paragraph-link"><span class="named-paragraph">Perform name inversion as necessary</span><span class="named-paragraph-number">4.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-it.html#SP4_3" class="named-paragraph-link"><span class="named-paragraph">Prefix and suffix as necessary</span><span class="named-paragraph-number">4.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="7-it.html#SP4_4" class="named-paragraph-link"><span class="named-paragraph">Relocate under a headword as necessary</span><span class="named-paragraph-number">4.4</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ip</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_LEMMA_SUBTERMS</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"too deep"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">ip</span><span class="plain-syntax">] = </span><span class="identifier-syntax">lemma</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">ip</span><span class="plain-syntax">] = </span><span class="identifier-syntax">ic</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4_1" class="paragraph-anchor"></a><b>&#167;4.1. </b>A category beginning <span class="extract"><span class="extract-syntax">!</span></span> is either redirected to a regular category, or
else suppressed as unwanted (because the user didn't set up a redirection).
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Redirect category names starting with an exclamation</span><span class="named-paragraph-number">4.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_name</span><span class="plain-syntax">) == </span><span class="character-syntax">'!'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">redirected</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Dictionaries::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">id</span><span class="plain-syntax">.</span><span class="element-syntax">categories_redirect</span><span class="plain-syntax">, </span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">redirected</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">Str::copy</span><span class="plain-syntax">(</span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_name</span><span class="plain-syntax">, </span><span class="identifier-syntax">redirected</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">erroneous</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-it.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_2" class="paragraph-anchor"></a><b>&#167;4.2. </b>This inverts "Sir Robert Cecil" to "Cecil, Sir Robert", but leaves
"Mary, Queen of Scots" alone.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Perform name inversion as necessary</span><span class="named-paragraph-number">4.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_inverted</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">lemma</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"%c*,%c*"</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Regexp::create_mr</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Regexp::match</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">lemma</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"(%c*?) (%C+) *"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">lemma</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">lemma</span><span class="plain-syntax">, </span><span class="string-syntax">"%S, %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="identifier-syntax">exp</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Regexp::dispose_of</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-it.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_3" class="paragraph-anchor"></a><b>&#167;4.3. </b>This, for example, could append "(monarch)" to the name of every lemma
in the category "royalty", so that "James I" becomes "James I (monarch)".
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Prefix and suffix as necessary</span><span class="named-paragraph-number">4.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rewritten</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">rewritten</span><span class="plain-syntax">, </span><span class="string-syntax">"%S%S%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_prefix</span><span class="plain-syntax">, </span><span class="identifier-syntax">lemma</span><span class="plain-syntax">, </span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_suffix</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Str::copy</span><span class="plain-syntax">(</span><span class="identifier-syntax">lemma</span><span class="plain-syntax">, </span><span class="identifier-syntax">rewritten</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">rewritten</span><span class="plain-syntax">)</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-it.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP4_4" class="paragraph-anchor"></a><b>&#167;4.4. </b>And this could automatically reroute the lemma so that it appears as
a subentry under the category's choice of headword: e.g., "James I"
might be placed as as a subentry of "Kings".
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Relocate under a headword as necessary</span><span class="named-paragraph-number">4.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">allow_relocation</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_under</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">normalised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">UN</span><span class="plain-syntax"> = </span><a href="7-it.html#SP2" class="function-link"><span class="function-syntax">IndexTerms::parse_normalised</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">ic</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">cat_under</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="7-it.html#SP4" class="function-link"><span class="function-syntax">IndexTerms::categorise_unrelocated</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="identifier-syntax">UN</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ip</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> += </span><span class="identifier-syntax">N</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-it.html#SP4">&#167;4</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::truncated</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::truncated</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">to</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">to</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">PT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PT</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> = </span><span class="identifier-syntax">to</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">j</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">j</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">to</span><span class="plain-syntax">; </span><span class="identifier-syntax">j</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">PT</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">j</span><span class="plain-syntax">] = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">j</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">PT</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">j</span><span class="plain-syntax">] = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">j</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">PT</span><span class="plain-syntax">.</span><span class="element-syntax">erroneous</span><span class="plain-syntax"> = </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">erroneous</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PT</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::serialise</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::serialise</span></span>:<br/>Indexing Data - <a href="7-id.html#SP2">&#167;2</a>, <a href="7-id.html#SP9">&#167;9</a><br/>Index Lemmas - <a href="7-il.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;0) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">":"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S=___=%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">], </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]-&gt;</span><span class="element-syntax">cat_name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::paraphrase</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::paraphrase</span></span>:<br/>General Index - <a href="7-gi.html#SP1_2_4_4">&#167;1.2.4.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">, </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;0) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">": "</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">indexing_category</span><span class="plain-syntax"> *</span><span class="function-syntax">IndexTerms::final_category</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::final_category</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">categories</span><span class="plain-syntax">[</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">-1];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">IndexTerms::final_text</span><span class="plain-syntax">(</span><span class="reserved-syntax">compiled_documentation</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cd</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">texts</span><span class="plain-syntax">[</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">-1];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::subterms</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::subterms</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP3">&#167;3</a><br/>General Index - <a href="7-gi.html#SP1_1">&#167;1.1</a>, <a href="7-gi.html#SP1_2_4">&#167;1.2.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">no_subterms</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">IndexTerms::erroneous</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">IndexTerms::erroneous</span></span>:<br/>Index Lemmas - <a href="7-il.html#SP9_1">&#167;9.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">categorised_term</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">erroneous</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="7-id.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-sm.html">1</a></li><li class="progresschapter"><a href="2-gnr.html">2</a></li><li class="progresschapter"><a href="3-bg.html">3</a></li><li class="progresschapter"><a href="4-em.html">4</a></li><li class="progresschapter"><a href="5-es.html">5</a></li><li class="progresschapter"><a href="6-st.html">6</a></li><li class="progresscurrentchapter">7</li><li class="progresssection"><a href="7-tm.html">tm</a></li><li class="progresssection"><a href="7-eip.html">eip</a></li><li class="progresssection"><a href="7-ti.html">ti</a></li><li class="progresssection"><a href="7-tc.html">tc</a></li><li class="progresssection"><a href="7-dc.html">dc</a></li><li class="progresssection"><a href="7-dr.html">dr</a></li><li class="progresssection"><a href="7-im.html">im</a></li><li class="progresssection"><a href="7-mrp.html">mrp</a></li><li class="progresssection"><a href="7-id.html">id</a></li><li class="progresscurrent">it</li><li class="progresssection"><a href="7-il.html">il</a></li><li class="progresssection"><a href="7-imn.html">imn</a></li><li class="progresssection"><a href="7-gi.html">gi</a></li><li class="progresssection"><a href="7-ei.html">ei</a></li><li class="progressnext"><a href="7-il.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

